package com.work.xxzl.adapter;


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * Created by Administrator on 2016/9/21 0021.
 * Tablayout适配器
 */
public class CommonFragmentPagerAdapter extends FragmentStatePagerAdapter {
    private String[] tabTitleArray;
    private List<Fragment> fragmentList;

    public CommonFragmentPagerAdapter(FragmentManager fm, List<Fragment> fragmentList, String[] tabTitleArray) {
        super(fm);
        this.fragmentList = fragmentList;
        this.tabTitleArray = tabTitleArray;
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabTitleArray[position % tabTitleArray.length];
    }

}
